package com.xm.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;

import com.xm.entity.Banners;
import com.xm.entity.Comdetail;
import com.xm.uti.DBManager;
import com.xm.uti.QueryDataResult;

/**
 * 公司信息持久层
 * 
 * @author 宋永正
 *
 */
public class ComdeDaoImp {
	 /**
	   * 单查
	   * 查询公司信息
	   * @param id
	   * @return
	   */
	  public Comdetail getCom() {
	    String sql = "select * from comdetail";
	    System.out.println("执行的sql语句是" + sql);
	    QueryDataResult execQuery = DBManager.executeQuery(sql);
	    Comdetail com=null;
	    if (execQuery != null) {
	      ResultSet rs = execQuery.rs;
	      try {
	        while (rs.next()) {
	          Comdetail e = new Comdetail();
	          e.setId(rs.getInt(1));
	          e.setComname(rs.getString("comname"));
	          e.setDetail(rs.getString("detail"));
	          e.setTel(rs.getString("tel"));
	          e.setZhaoShang(rs.getString("zhaoShang"));
	          e.setAddress(rs.getString("address"));
	          e.setEmail(rs.getString("email"));
	          e.setCulture(rs.getString("culture"));
	          e.setJianjie(rs.getString("jianjie"));
	          e.setX(rs.getDouble("x"));
	          e.setY(rs.getDouble("y"));
	          return e;
	        }
	      } catch (SQLException e) {
	        // TODO Auto-generated catch block
	        e.printStackTrace();
	      } finally {
	        execQuery.close();
	      }
	    }
	    return com;
	  }

	/**
	 * 修改
	 * 
	 * @param emp
	 * @return
	 */
	public boolean updateCom(Comdetail comdetail) {
		System.out.println("公司表的数据是" + comdetail);
		String sql = "update comdetail set comname='" + comdetail.getComname() + "',detail='" + comdetail.getDetail() + "',zhaoShang='"
				+ comdetail.getZhaoShang() + "',tel='" + comdetail.getTel() + "',address='" + comdetail.getAddress() + "',email='"
				+ comdetail.getEmail() + "',culture='" + comdetail.getCulture() + "',jianjie='" + comdetail.getJianjie() + "',x='" 
				+ comdetail.getX() + "',y='" + comdetail.getY() + "' where id =" + comdetail.getId();
		int i = DBManager.executeUpdate(sql);
		if (i > 0) {
			return true;
		}
		return false;
	}
	
	
}
